//
//  ThirdViewController.m
//  HappinessTrip
//
//  Created by dllo on 15/10/16.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "ThirdViewController.h"
#import "Fit.h"
#import "MBProgressHUD.h"

@interface ThirdViewController ()<UIWebViewDelegate>
@property(nonatomic, retain)UIWebView *webView;
@property(nonatomic, retain)MBProgressHUD *progressView;

@end

@implementation ThirdViewController
-(void)dealloc
{
    [_webView release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    
}
-(void)loadView
{
    [super loadView];
    self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, - 45 * H, self.view.frame.size.width, self.view.frame.size.height + 45 * H - 64)];
    _webView.scrollView.bounces = NO;
    _webView.delegate = self;
    [self.view addSubview:self.webView];
    [_webView release];
    
    
    NSArray *array = [_url componentsSeparatedByString:@"/"];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://web.breadtrip.com/mobile/destination/%@/%@/%@/", array[2], array[3], _string]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [_webView loadRequest:request];
    
    //加载视图初始化
    self.progressView = [[MBProgressHUD alloc]initWithView:self.view];
    _progressView.labelText = @"玩命加载中";
    [_progressView setMode:MBProgressHUDModeIndeterminate];
    [_progressView show:YES];
    _progressView.backgroundColor = [UIColor colorWithRed:0.73 green:0.76 blue:0.77 alpha:.3];
    [self.view addSubview:_progressView];
    [_progressView release];
    
}

-(void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = YES;
}

-(void)viewWillDisappear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = NO;
}

-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    [_progressView removeFromSuperview];
}

//-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
//{
//    NSString *urlString = request.URL.absoluteString;
//    if ([urlString hasPrefix:@"http://www"]||[urlString hasPrefix:@"http://m."]||[urlString hasPrefix:@"http://v."]) {
//        //_searchURLView.inputView是一个textField改成的地址栏
//        _webView.inputView = urlString;
//    }
//    return YES;
//}



















- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
